package com.maple.mapper;

import com.github.pagehelper.Page;
import com.maple.annotation.MyType;
import com.maple.dto.EmployeePageQueryDTO;
import com.maple.entity.Employee;
import com.maple.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

public interface EmployeeMapper {

    /**
     * 用户登陆
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增用户
     */
    @MyType(value = OperationType.INSERT)
    @Insert("insert into employee(name, username,password, phone, sex, id_number, create_time, update_time, create_user, update_user, status)\n" +
            "        VALUES" +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    void saveEmployee(Employee employee);

    /**
     * 分页查询
     * @param pageQueryDTO
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO pageQueryDTO);

    /**
     * 更新数据
     * @param emp
     */
    @MyType(value = OperationType.UPDATE)
    void updata(Employee emp);

    /**
     * 通过id查询员工
     * @param id
     * @return
     */
    Employee queryById(String id);
}
